﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AMail.Common.Interfaces.Data;

namespace AMail.Common.Interfaces.Services
{
  /// <summary>
  /// This service provides Archive-UI functionality
  /// </summary>
  public interface IArchiveService
  {
    /// <summary>
    /// Try to open the requested archive file
    /// (displays the password dialog, etc...).
    /// Returns true if file was opened successfuly.
    /// </summary>
    /// <param name="filename"></param>
    /// <returns></returns>
    bool OpenArchive(string filename);

    /// <summary>
    /// Opens the OpenFileDialog and then tries to open
    /// the file selected by the user (shows the password dialog, etc...)
    /// </summary>
    /// <returns></returns>
    bool OpenArchive();

    /// <summary>
    /// Try to create a new archive (ask the user for
    /// the name and password of the new archive).
    /// Returns true if a new archive was created.
    /// </summary>
    /// <returns></returns>
    bool CreateNewArchive();

    /// <summary>
    /// Tries to close the active archive
    /// (displays a confirmation if it has unsaved changes).
    /// Returns true if it was closed sucessfully.
    /// </summary>
    /// <returns></returns>
    bool CloseActiveArchive();

    /// <summary>
    /// Saves the active archive.
    /// Returns <c>true</c> if the archive was saved successfuly.
    /// </summary>
    bool SaveActiveArchive();

    /// <summary>
    /// If the active archive has unsaved changes, this method
    /// will show the user a message asking whether he would like
    /// to save the changes, discard the changes or cancel.
    /// <para>
    /// If the user selects "Yes" it will try to save the changes
    /// and if sucessful, it will return true (otherwise returns false).
    /// </para>
    /// <para>
    /// If the user selects "No" it will return true.
    /// </para>
    /// <para>
    /// If the user selects "Cancel" it will return false.
    /// </para>
    /// </summary>
    /// <returns></returns>
    bool CanCloseActiveArchive();

    /// <summary>
    /// Returns true if there's an active archive
    /// and it has unsaved changes
    /// </summary>
    bool ActiveArchiveHasUnsavedChanges { get; }

    /// <summary>
    /// Returns the active archive
    /// </summary>
    IMailArchive ActiveArchive { get; }

    /// <summary>
    /// Reverts to the saved version of the archive (reopens the archive)
    /// </summary>
    void Revert();

    /// <summary>
    /// Changes the archive's password
    /// </summary>
    void ChangePassword();
  }
}
